package fastwave.cloud.demo.sz.controller;

import fastwave.cloud.demo.fastwavelibcommon.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RefreshScope
@RequestMapping("/config")
public class ConfigController {

    @Value("${custom.key1}")
    String key1;

    @Value("${custom.key2}")
    String key2;

    @GetMapping("/getKey")
    public R byHttpGet(@RequestParam Map<String, Object> params)
    {
        if(params.get("key").toString().equals("key1"))
        {
            return R.ok(key1);
        }
        return R.ok(key2);
    }
}
